package com.person.yan.takeout2017.net;

import com.google.gson.Gson;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by ywy on 2017-09-28.
 */

public class HttpUtils {

    private static TakeOutApi takeOutApi;

    public static TakeOutApi getApi(){

        if(takeOutApi==null){

            /**初始化*/
            //1初始化Retrofit框架
            Retrofit builder = new Retrofit.Builder()
                    //2配置主机地址
                    .baseUrl("http://10.0.2.2:8080/TakeoutServer/")
                    //3解析json的工具
                    .addConverterFactory(GsonConverterFactory.create(new Gson()))
                    .build();

            //读取接口上面的参数
            takeOutApi = builder.create(TakeOutApi.class);
        }

        return takeOutApi;
    }
}
